package com.deyuanyun.pic.pbf.controller.dto.defect;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.pbf.domain.DefectInfo;
import com.deyuanyun.pic.settings.domain.base.Attachment;
import com.deyuanyun.pic.settings.support.biz.AttachmentUtil;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.wf.support.ProcessDefinitionUtil;
import org.springframework.validation.Errors;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Created by linwei on 6/17/2016.
 */
public class DefectInfoDto implements Command<DefectInfo> {

    /**
     * 主键
     */
    private String id;

    /**
     * 缺陷编号
     */
    private String DefectNumber;

    /**
     * 管道名称
     */
    private String pipeLineName;

    /**
     * 缺陷类型
     */
    private String featureType;

    /**
     * 缺陷子类型
     */
    private String featureSubtype;

    /**
     * 时钟位置
     */
    private String clock;

    /**
     * 长（mm）
     */
    private BigDecimal length;

    /**
     * 宽（mm）
     */
    private BigDecimal width;

    /**
     * 深（mm）
     */
    private BigDecimal depth;

    /**
     * 绝对距离(m)
     */
    private BigDecimal mileage;

    /**
     * 链接GIS结果表
     */
    private String gisId;

    /**
     * 缺陷来源：INSP，内检测；UNINSP，非内检测；TRENCH，同沟新增缺陷
     */
    private String featureResource;

    /**
     * ERF值
     */
    private BigDecimal erf;

    /**
     * 评价维修建议：立即维修；计划维修；暂不维修；监控
     */
    private String repairSuggestion;

    /**
     * 评价最迟修复时间
     */
    private Date planRepairTime;

    /**
     * 评价维修方法：玻璃纤维补强；劳伦纤维补强；碳纤维补强；A型套管；B型套管；环氧套管；接管；打磨；补焊；补丁；共具；其他
     */
    private String planRepairType;

    /**
     * 评价时间
     */
    private Date evaluateTime;

    /**
     * 评价单位
     */
    private String assessDepartment;

    /**
     * 修复时间
     */
    private Date repairTime;

    /**
     * 修复方法
     */
    private String repairType;

    /**
     * 修复单位
     */
    private String repairDepartment;

    /**
     * 修复备注
     */
    private String repairRemark;

    /**
     * 维修工作量
     */
    private String repairWorkload;

    /**
     * 维修状态：待维修；修复中；难以维修；已维修
     */
    private String repairState;

    /**
     * 图片
     */
    private List<ImgDto> imgList;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDefectNumber() {
        return DefectNumber;
    }

    public void setDefectNumber(String defectNumber) {
        DefectNumber = defectNumber;
    }

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getFeatureType() {
        return featureType;
    }

    public void setFeatureType(String featureType) {
        this.featureType = featureType;
    }

    public String getFeatureSubtype() {
        return featureSubtype;
    }

    public void setFeatureSubtype(String featureSubtype) {
        this.featureSubtype = featureSubtype;
    }

    public String getClock() {
        return clock;
    }

    public void setClock(String clock) {
        this.clock = clock;
    }

    public BigDecimal getLength() {
        return length;
    }

    public void setLength(BigDecimal length) {
        this.length = length;
    }

    public BigDecimal getWidth() {
        return width;
    }

    public void setWidth(BigDecimal width) {
        this.width = width;
    }

    public BigDecimal getDepth() {
        return depth;
    }

    public void setDepth(BigDecimal depth) {
        this.depth = depth;
    }

    public BigDecimal getMileage() {
        return mileage;
    }

    public void setMileage(BigDecimal mileage) {
        this.mileage = mileage;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public String getFeatureResource() {
        return featureResource;
    }

    public void setFeatureResource(String featureResource) {
        this.featureResource = featureResource;
    }

    public BigDecimal getErf() {
        return erf;
    }

    public void setErf(BigDecimal erf) {
        this.erf = erf;
    }

    public String getRepairSuggestion() {
        return repairSuggestion;
    }

    public void setRepairSuggestion(String repairSuggestion) {
        this.repairSuggestion = repairSuggestion;
    }

    public Date getPlanRepairTime() {
        return planRepairTime;
    }

    public void setPlanRepairTime(Date planRepairTime) {
        this.planRepairTime = planRepairTime;
    }

    public String getPlanRepairType() {
        return planRepairType;
    }

    public void setPlanRepairType(String planRepairType) {
        this.planRepairType = planRepairType;
    }

    public Date getEvaluateTime() {
        return evaluateTime;
    }

    public void setEvaluateTime(Date evaluateTime) {
        this.evaluateTime = evaluateTime;
    }

    public String getAssessDepartment() {
        return assessDepartment;
    }

    public void setAssessDepartment(String assessDepartment) {
        this.assessDepartment = assessDepartment;
    }

    public Date getRepairTime() {
        return repairTime;
    }

    public void setRepairTime(Date repairTime) {
        this.repairTime = repairTime;
    }

    public String getRepairType() {
        return repairType;
    }

    public void setRepairType(String repairType) {
        this.repairType = repairType;
    }

    public String getRepairDepartment() {
        return repairDepartment;
    }

    public void setRepairDepartment(String repairDepartment) {
        this.repairDepartment = repairDepartment;
    }

    public String getRepairRemark() {
        return repairRemark;
    }

    public void setRepairRemark(String repairRemark) {
        this.repairRemark = repairRemark;
    }

    public String getRepairWorkload() {
        return repairWorkload;
    }

    public void setRepairWorkload(String repairWorkload) {
        this.repairWorkload = repairWorkload;
    }

    public String getRepairState() {
        return repairState;
    }

    public List<ImgDto> getImgList() {
        return imgList;
    }

    public void setImgList(List<ImgDto> imgList) {
        this.imgList = imgList;
    }

    public void setRepairState(String repairState) {
        this.repairState = repairState;
    }

    @Override
    public DefectInfo toDomain(Errors errors) {
        return null;
    }

    @Override
    public DefectInfo toDomain() {
        return null;
    }

    @Override
    public void fromDomain(DefectInfo domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }

        this.id = domain.getId();
        this.DefectNumber = domain.getCustomNumber();
        this.pipeLineName = domain.getPipeLineId();
        this.featureType = CodeUtil.getName(domain.getFeatureType());
        this.featureSubtype = CodeUtil.getName(domain.getFeatureSubtype());
        this.clock = domain.getClock();
        this.length = domain.getLength();
        this.width = domain.getWidth();
        this.depth = domain.getDepth();
        this.mileage = domain.getMileage();
        this.gisId = domain.getGisId();
        this.featureResource = CodeUtil.getName(domain.getFeatureResource());
        this.erf = domain.getErf();
        this.repairSuggestion = CodeUtil.getName(domain.getRepairSuggestion());
        this.planRepairTime = domain.getPlanRepairTime();
        this.planRepairType = ProcessDefinitionUtil.getProcessDefinitionName(domain.getPlanRepairType());
        this.evaluateTime = domain.getEvaluateTime();
        this.assessDepartment = domain.getAssessDepartment();
        this.repairTime = domain.getRepairTime();
        this.repairType = ProcessDefinitionUtil.getProcessDefinitionName(domain.getRepairType());
        this.repairDepartment = domain.getRepairDepartment();
        this.repairRemark = domain.getRepairRemark();
        this.repairWorkload = domain.getRepairWorkload();
        this.repairState = domain.getRepairState();

        this.imgList = ImgDto.queryImgDtoList(domain.getId());
    }
}
